﻿function funFormReset() {
	$('#userVo_userLoginId')[0].value = "";
	$('#userVo_password')[0].value = "";
}

function eventOnkeypress(eve, type) {// 事件处理
	if (eve.keyCode == 13) {
		try {
			if (type == 1) {
				if ($('#userVo_userLoginId')[0].value != "") {
					$('#userVo_password')[0].focus();
				}
			} else {
				if ($('#userVo_password')[0].value != "") {
					$('#OK')[0].click();
				}
			}
			eve.keyCode = 0;
		} catch (e) {
		}
		return;
	}
}

// 用户注册
function toUserRegister() {
	var dform = document.all.dataform1;
	dform.action = "admin/UserAction!initUserRegister.action";
	dform.target = "_self";
	dform.submit();
}



// 用户登陆
function funUserLogin() {
	if ($('#userVo_userLoginId')[0].value == "") {
		$.messager.alert('输入错误', '登陆名不能为空!', 'error');
	} else if ($('#userVo_password')[0].value == "") {
		$.messager.alert('输入错误', '密码不能为空!', 'error');
	} else {
		var dform = document.all.dataform1;
		dform.action = "admin/UserAction!userLogin.action";
		dform.target = "_self";
		dform.submit();
	}
}

// 重置
function toResultForm() {

}

// 忘记密码
function callManageClick() {
	alert("当前功能未实现");
}

// 打开用户注册
function funOpenUserRegister() {
	$('#winUserRegister').window('open');
}

// 打开用户注册
function funCloseUserRegister() {
	$('#winUserRegister').window('close');
}


function funUserRegister() {// 用户注册
	var vform = $('#registerForm')[0];
	if(vform['userVo.userLoginId'].value == "" || vform['userVo.password'].value == ""){
		return;
	}else{
		$.ajax({
			contentType : "application/x-www-form-urlencoded",
			data : {
				'userVo.userLoginId' : vform['userVo.userLoginId'].value,
				'userVo.password' : vform['userVo.password'].value,
				'userVo.securityType':vform['userVo.securityType'].value,
				'userVo.passCoding':vform['userVo.passCoding'].value,
				'userVo.remark':vform['userVo.remark'].value
			},
			dataType : "json",
			type : "POST",
			timeout : "3000",
			beforeSend : ajaxBeforeSend,
			error : ajaxError,
			success : ajaxSuccess,
			url : "admin/UserAjaxAction!userRegister.action"
		});
	}
}

function ajaxSuccess(data) {
	//alert(JSON.stringify(data));
	if(data.dataset.success == false){
		$.messager.alert('注册失败',data.dataset.return_info,'error');
	}else{
		funCloseUserRegister();
		$.messager.alert('注册成功',"注册成功",'info');
	}
}

function ajaxError(data) {
	$.messager.alert('程序失败',"调用异常，请联系管理员。",'error');
}

function ajaxBeforeSend(data) {
}